[Schema][Server] Add MCP Apps extension (io.modelcontextprotocol/ui) support#281
[Schema][Server] Add MCP Apps extension (io.modelcontextprotocol/ui) support#281chr-hertel wants to merge 5 commits into
Conversation
9c9b41b to
d9ca7e6
Compare
d9ca7e6 to
ea82312
Compare
1f1c1c6 to
f1a76a6
Compare
2039755 to
cf9ee8e
Compare
|
This could use some love as follow up when it comes to the Builder. maybe a |
cf9ee8e to
fda2228
Compare
| * | ||
| * @author Christopher Hertel <mail@christopher-hertel.de> | ||
| */ | ||
| final class UiResourcePermissions implements \JsonSerializable |
There was a problem hiding this comment.
🟡 risk — Permission set hardcoded to 4 entries (camera/microphone/geolocation/clipboardWrite). If the spec adds new permissions, fromArray() silently drops them and jsonSerialize() cannot emit them.
Fix: keep unknown keys as passthrough (array<string, \stdClass>) or document the closed set explicitly.
There was a problem hiding this comment.
this refers to the actual spec and is mapped to concrete properties - if we go down the road of opening the spec for dynamics that would be quite a stunt and i'd rather argue that these DTOs should be exactly like the spec.
| final class McpApps implements ServerExtensionInterface | ||
| { | ||
| public const EXTENSION_ID = 'io.modelcontextprotocol/ui'; | ||
| public const MIME_TYPE = 'text/html;profile=mcp-app'; |
There was a problem hiding this comment.
❓ question — MIME constant text/html;profile=mcp-app. RFC 6838 typically quotes the profile parameter (profile="mcp-app"). Is the unquoted form spec-mandated by io.modelcontextprotocol/ui, or just copied loosely?
There was a problem hiding this comment.
It's how the spec documented it:
https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx
Adds support for the MCP Apps protocol extension, which lets servers expose interactive HTML UIs as resources rendered by spec-conforming clients (e.g. Goose) in sandboxed iframes. - Generic extension plumbing: ServerExtensionInterface and Builder::enableExtension(), with extensions advertised under capabilities.extensions during the initialize handshake. ClientCapabilities/ServerCapabilities gain an extensions field. - Schema DTOs under Mcp\Schema\Extension\Apps: the McpApps marker, UiToolMeta, ToolVisibility enum, UiResourceContentMeta, UiResourceCsp, and UiResourcePermissions (with empty-object presence markers per spec). - A worked weather example under examples/server/mcp-apps/ with a minimal spec-conforming view (ui/initialize handshake, postMessage JSONRPCMessage objects, and ResizeObserver-driven size reporting). - docs/extensions.md guide with pointers from index.md and examples.md to the ext-apps repository for the TypeScript SDK and richer view-side patterns. - Unit and inspector snapshot test coverage. Spec: https://github.com/modelcontextprotocol/ext-apps
Also fix UiResourceContentMeta::jsonSerialize() return phpdoc. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2740916 to
b8614b7
Compare
- Pin the is_array() guards on extensions in ServerCapabilities and ClientCapabilities::fromArray() with explicit non-array payload tests. - Pin the isset()-rejects-null contract in UiResourcePermissions::fromArray(). - Surface the new extensions field on both capability classes in CHANGELOG. - Inline the ?: idiom in Builder::build() to match the surrounding style. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Mcp\Schema\Extension\Apps\for the MCP Apps extension (io.modelcontextprotocol/ui, spec2026-01-26)extensionsfield to bothServerCapabilitiesandClientCapabilitiesfor extension negotiationToolVisibilityenum (model/app)examples/server/mcp-apps/demonstrating UI resources and tool-UI linkageDetails
The MCP Apps extension enables servers to expose interactive HTML UI applications as MCP resources. This PR adds server-side support:
McpApps(constants/helpers),UiResourceCsp,UiResourcePermissions,UiResourceContentMeta,UiToolMeta— all withfromArray()/jsonSerialize()andtoMetaArray()helpers for embedding in_metaextensionsparameter on both capability classes (backward-compatible, defaults tonull)resources/list,resources/read,tools/list,tools/callui/initialize,ui/open-link, etc.) which runs between the rendered HTML and the host applicationTest plan
make cs— coding standards passmake phpstan— static analysis passes (0 errors)make unit-tests— all 754 tests pass (34 new)npx @modelcontextprotocol/inspector php examples/server/mcp-apps/server.phpRunning in Goose
Screencast.from.2026-05-11.23-45-55.webm